package com.newblog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newblog.model.ArticleInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2023-12-11
 * Time:16:22
 * Text：
 */
@Mapper
public interface ArticleMapper extends BaseMapper<ArticleInfo> {
    //@Param()是为了与#{}语句使用

//删除文章
    @Delete("delete from articleinfo where articleId=#{articleId} and userId=#{userId}")
    int delete(@Param("articleId")Integer aid,@Param("userId")int userId);
//修改自身文章
    @Update("update articleinfo set title=#{title},content=#{content} where userId=#{userId} and articleId=#{articleId}")
    int update(ArticleInfo art);
//查询该用户下有多少文章
    @Select("select count(*) from articleinfo where userid=#{userid}")
   int getDetailById(@Param("userid")Integer id);

    @Update("update articleinfo set rcount=rcount+1 where articleId=#{articleId}")
    int getinsert(@Param("articleId")int userId);
                                                                        //几个        偏移量
    @Select("select * from articleinfo order by articleId desc limit #{paszie} offset #{ofset}")
    List<ArticleInfo> getListByPage(@Param("paszie")Integer pasize ,@Param("ofset")Integer ofest);

    @Select("select count(*) from articleinfo")
    int getCount();
}
